package com.hanfu.ucenter.web.web.dto.Response;

import com.hanfu.ucenter.web.exception.ErrorCode;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;

/**
 * @Author: jun
 * @Date: 2019/6/27 13:50
 * @Description: 返回数据给前端的数据模型
 */

    @Data
    public class Result<T> implements Serializable {

        /*状态码*/
        //@ApiModelProperty(position =0,value = "状态码",notes = "1为成功 -1为token失效,否则详情见失败信息")
        private int code;

       // @ApiModelProperty(position = 1,value = "返回数据",notes = "请求结果的数据正文，可能为空")
        private T data;

        //@ApiModelProperty(position = 2,value = "提示信息",notes="具体的提示信息")
        private String msg;

        public Result(int code, String msg, T data) {
            this.code = code;
            this.msg = msg;
            this.data = data;
        }

        public static  Result error(String msg) {
            return new Result(Integer.parseInt(ErrorCode.PARAMS_ERROR.getCode()),msg,null);
        }
    }


